<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    .alert {
      padding: 10px 20px;
      margin-bottom: 20px;
      color: #333;
    }
    .alert-danger {
      border: 1px solid #f09898;
      background: #f3beb8;
    }
    .alert-success {
      border: 1px solid #78ff74;
      background: #98f0ba;
    }
  </style>
</head>
<body>
  <div id="app">
    <alert type="danger">发生错误</alert>
    <alert type="success">成功</alert>

  </div>
  <script src="./vue.js"></script>
  <script>
    Vue.component('alert', {
      template: `
        <div class="alert" :class="{
          'alert-danger': type === 'danger',
          'alert-success': type === 'success'
        }">
          <strong>{{type === "danger" ? 'Error!' : 'Success!'}}</strong><slot></slot>
        </div>
      `,
      props: {
        type: String
      }
    })


    const app = new Vue({
      el: '#app',
      data: {

      }
    })
  
  </script>
</body>
</html>